Skip to content

refactor: native macOS patterns for keyboard nav, search fields, and resize handle#598

Merged
datlechin merged 8 commits intomainfrom
refactor/medium-audit-fixes
Apr 6, 2026
Merged

refactor: native macOS patterns for keyboard nav, search fields, and resize handle#598
datlechin merged 8 commits intomainfrom
refactor/medium-audit-fixes

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Three medium-effort audit fixes replacing custom implementations with native macOS patterns:

  • Connection Switcher keyboard nav — Replaced NSEvent.addLocalMonitorForEvents(matching: .keyDown) with SwiftUI .onKeyPress() + .onExitCommand. Eliminates global key interception and manual install/teardown lifecycle. Pattern matches QuickSwitcherView which already does this correctly.

  • Reusable SearchFieldView — Extracted identical HStack + magnifying glass + TextField + clear button pattern from 4 views into a single SearchFieldView component. Reduces ~80 lines of duplicated code. WelcomeWindowView excluded (has extensive view-specific key handlers).

  • Inspector panel resize — Replaced custom PanelResizeHandle (DragGesture + manual NSCursor) with HorizontalSplitView wrapping NSSplitView. Gains native divider cursor, autosave position, accessibility support, and proper drag feel. Pattern matches existing QuerySplitView.

Test plan

  • Connection Switcher popover: arrow keys navigate, Ctrl+J/K navigate, Return selects, Escape dismisses
  • Quick Switcher (Cmd+P): search field looks the same, clear button works, focus works
  • Database Switcher (Cmd+K): search field looks the same
  • Settings > Keyboard: search field works
  • Right Sidebar: search field works with smaller font
  • Inspector panel: drag divider to resize, position persists across sessions
  • Inspector panel: toggle open/close, smooth transition
  • Inspector panel: respects min/max width constraints

- SearchFieldView: resolve theme font size inside body for reactivity
- HorizontalSplitView: refresh binding in updateNSView to prevent stale reference
- HorizontalSplitView: add 0.5pt threshold to resize callback to reduce re-renders
- HorizontalSplitView: remove redundant splitView.display() calls
- ConnectionSwitcherPopover: extract moveSelection helper to avoid repeated allItems computation
- ContentView: remove dead saveCurrentSessionState stub
@datlechin datlechin merged commit c873885 into main Apr 6, 2026
2 checks passed
@datlechin datlechin deleted the refactor/medium-audit-fixes branch April 6, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant